<?php include "php5.php"; ?>
<?php include "config.php"; ?>
<?php
	$links = "";
	$links_path = "";
	$section_path = "";
	$allowed_files = "";
	if ($mambot && file_exists("../../configuration.php")) {
		define( '_VALID_MOS', 1 );
		include ("../../configuration.php");
		if( file_exists( $mosConfig_absolute_path."/includes/joomla.php" ) ){
			require_once ( $mosConfig_absolute_path."/includes/joomla.php" );
		}else{
			require_once ( $mosConfig_absolute_path."/includes/mambo.php" );
		}
		$database = new database( $mosConfig_host, $mosConfig_user, $mosConfig_password, $mosConfig_db, $mosConfig_dbprefix );
		$query = "";
		if ($_GET["section"] == "Articles") {
			$query = "SELECT a.id AS value, a.title AS text, CONCAT( '/index.php?option=com_content&amp;task=view&amp;id=', a.id) AS href FROM #__content AS a WHERE a.state = '1' AND a.sectionid != '0' ORDER BY a.title";
		} else if ($_GET["section"] == "Static Content") {
			$query = "SELECT a.id AS value, a.title AS text, CONCAT( '/index.php?option=com_content&amp;task=view&amp;id=', a.id) AS href FROM #__content AS a WHERE a.state = '1' AND a.sectionid = '0' ORDER BY a.title";
		} else if ($_GET["section"] == "Category") {
			$query = "SELECT a.id AS value, a.title AS text, CONCAT( '/index.php?option=com_content&amp;task=category&amp;sectionid=', a.section, '&amp;id=', a.id) AS href FROM #__categories AS a LEFT JOIN #__sections AS s ON s.id WHERE a.published = '1' AND s.id = a.section ORDER BY a.title";
		} else if ($_GET["section"] == "Section") {
			$query = "SELECT a.id AS value, a.title AS text, CONCAT( '/index.php?option=com_content&amp;task=section&amp;id=', a.id) AS href FROM #__sections AS a WHERE a.published = '1' AND a.scope='content' ORDER BY a.title";
		} else if ($_GET["section"] == "Contact") {
			$query = "SELECT a.id AS value, a.name AS text, CONCAT( '/index.php?option=com_contact&amp;task=view&amp;contact_id=', a.id) AS href FROM #__contact_details AS a WHERE a.published = '1' ORDER BY a.name";
		}
		if ($query) {
		        $database->setQuery( $query );
		        $contents = $database->loadObjectList( );
		}
	}
	if ($root_path <> "") {
		if (($pages_path <> "") && ($_GET["section"] == "Pages")) {
			$section_path = $pages_path;
			$allowed_files = "\.(" . str_replace(",", "|", $page_formats) . ")$";
		}
		if (($images_path <> "") && ($_GET["section"] == "Images")) {
			$section_path = $images_path;
			$allowed_files = "\.(" . str_replace(",", "|", $image_formats) . ")$";
		}
		if (($files_path <> "") && ($_GET["section"] == "Files")) {
			$section_path = $files_path;
			$allowed_files = "\.(" . str_replace(",", "|", $file_formats) . ")$";
		}
		if ($section_path <> "") {
			if (is_dir($root_path . $section_path . $_GET["category"])) {
				$links = opendir($root_path . $section_path . $_GET["category"]);
				if ($_GET["category"] == "/") {
					$links_path = $section_path;
				} else {
					$links_path = $section_path . $_GET["category"];
				}
			}
		}
	}
?>
<?php include "hyperlinklist.php.html"; ?>
<?php
	if ($links) closedir($links);
?>
